package com.topc.code.judge;


import com.topc.code.judge.strategy.*;
import com.topc.problem.model.code.JudgeInfo;
import com.topc.problem.model.enums.LanguageTypeEnum;
import com.topc.problem.model.po.ProblemContentCommit;
import com.topc.problem.model.po.ProblemUserMid;
import org.springframework.stereotype.Service;

@Service
public class JudgeManager {
    public JudgeContext doJudge(JudgeContext judgeContext){
//        ProblemUserMid questionSubmit = judgeContext.getProblemUserMid();
        Integer codeType = judgeContext.getProblemContentCommit().getCodeType();
        String language = LanguageTypeEnum.getEnumByText(codeType).getValue();
        //根据语言类型选择不同的策略
        JudgeStrategy judgeStrategy;
        switch (language){
            case "java":
                judgeStrategy=new JavaLanguageJudgeStrategy();
                break;
            case "cpp":
                judgeStrategy=new CppLanguageJudgeStrategy();
                break;
            default:
                judgeStrategy=new DefaultJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
